import { ccs } from "../../util/services";
import { KeyObject, playerType, skillType, studyModel } from "../gameType";

export default class skillModel {

    skillMap: KeyObject<skillType>[] =  [];

    _init() {
        //
    }
    //生成技能
    randomSkill() {
        
    }
    //学习技能
    learnSkill(player: playerType, skill: studyModel) {
        let curSkill: skillType = null;
        skill.learn.forEach(val => {
            curSkill =  player.skill[val.id];
            if(val.max > curSkill.level) {
                //当前等级未达到培训的最高级
                curSkill.curExp += val.exp * (1 + (player.learn - 100)/100);
                if(curSkill.curExp >= curSkill.exp[curSkill.level - 1]) {
                    //升级
                    player.skill.find(item => item.id == val.id).level++;
                }
            }
        })
    }
    unlockSkill() {

    }

}